home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 December
/
MACPOWER-1997-12.ISO.7z
/
MACPOWER-1997-12.ISO
/
AMUG
/
PROGRAMMING
/
Raven 1.2 Examples.sit
/
Raven 1.2 Examples
/
Quill
/
Source
/
CachedViewEditor.cpp
< prev
next >
Wrap
Text File
|
1997-08-08
|
4KB
|
157 lines
/*
* File: CachedViewEditor.cpp
* Summary: A view that knows how to edit a TCachedView.
* Written by: Jesse Jones
*
* Copyright ゥ 1996 Jesse Jones.
* For conditions of distribution and use, see copyright notice in ZTypes.h
*
* Change History (most recent first):
*
* <-> 12/01/96 JDJ Created
*/
#include "CachedViewEditor.h"
#include <ZDialogUtils.h>
#include <ZTextBox.h>
// ===================================================================================
// class CEditCachedViewCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CEditCachedViewCommand::~CEditCachedViewCommand
//
//---------------------------------------------------------------
CEditCachedViewCommand::~CEditCachedViewCommand()
{
}
//---------------------------------------------------------------
//
// CEditCachedViewCommand::CEditCachedViewCommand
//
//---------------------------------------------------------------
CEditCachedViewCommand::CEditCachedViewCommand(TCachedView* pane, const SCachedViewInfo& oldInfo, const SCachedViewInfo& newInfo) : Inherited(pane, oldInfo, newInfo)
{
}
//---------------------------------------------------------------
//
// CEditCachedViewCommand::UpdatePane
//
//---------------------------------------------------------------
void CEditCachedViewCommand::UpdatePane(const SCachedViewInfo& info)
{
mPane->SetColorTable(info.colorTableID);
mPane->SetDepth(info.depth);
}
#pragma mark -
// ===================================================================================
// CCachedViewEditor
// ===================================================================================
static TReanimatorRegister<CCachedViewEditor> sCachedViewEditorRegistrar;
//---------------------------------------------------------------
//
// CCachedViewEditor::~CCachedViewEditor
//
//---------------------------------------------------------------
CCachedViewEditor::~CCachedViewEditor()
{
}
//---------------------------------------------------------------
//
// CCachedViewEditor::CCachedViewEditor
//
//---------------------------------------------------------------
CCachedViewEditor::CCachedViewEditor(TView* superView) : Inherited(superView)
{
}
//---------------------------------------------------------------
//
// CCachedViewEditor::Create [static]
//
//---------------------------------------------------------------
MReanimatable* CCachedViewEditor::Create(MReanimatable* parent)
{
return new CCachedViewEditor(dynamic_cast<TView*>(parent));
}
//---------------------------------------------------------------
//
// CCachedViewEditor::Validate
//
//---------------------------------------------------------------
bool CCachedViewEditor::Validate()
{
bool valid = Inherited::Validate();
if (valid) {
TTextBox* textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Depth"));
short depth = textBox->GetValue();
if (depth != 1 && depth != 4 && depth != 8 && depth != 16 && depth != 32) {
DoStop(LoadAppString("That's not a valid bit depth!"), "");
textBox->SelectAll();
valid = false;
}
}
return valid;
}
//---------------------------------------------------------------
//
// CCachedViewEditor::GetEditorInfo
//
//---------------------------------------------------------------
SCachedViewInfo CCachedViewEditor::GetEditorInfo() const
{
SCachedViewInfo info;
TTextBox* textBox = nil;
textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Clut"));
info.colorTableID = textBox->GetValue();
textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Depth"));
info.depth = textBox->GetValue();
return info;
}
//---------------------------------------------------------------
//
// CCachedViewEditor::SetEditorInfo
//
//---------------------------------------------------------------
void CCachedViewEditor::SetEditorInfo(const SCachedViewInfo& info)
{
TTextBox* textBox = nil;
textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Clut"));
textBox->SetValue(info.colorTableID);
textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Depth"));
textBox->SetValue(info.depth);
}